package cn.itcast.redisdemo.service;

import cn.itcast.redisdemo.anno.RepeatLock;
import cn.itcast.redisdemo.mapper.AccountMapper;
import cn.itcast.redisdemo.pojo.AccountMobal;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Slf4j
public class HelloServiceImpl implements HelloService{
    
    @Resource
    AccountMapper accountMapper;
    @Resource
    private DataSourceTransactionManager txManager;
    @Override
    @RepeatLock
    @Transactional
    public void testLockAnno() throws InterruptedException {
      
        
        accountMapper.insert(AccountMobal.builder().balance(111).build());
        int a = 1/0;
        log.error("方法执行结束--------");
    }
}
